package com.itheima.validation;

import com.itheima.annotation.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * Article实体中state字段的校验规则
 */
public class StateValidation implements ConstraintValidator<State,String> {

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        // 提供校验规则
        if(s == null) {
            return false;
        }
        if("已发布".equals(s) || "草稿".equals(s)) {
            return true;
        }
        return false;
    }
}
